// 引入 dotenv 库并加载环境变量
import 'dotenv/config';

import { createServer } from "node:http";
import app from "./app.js";
import WebSocketServerClass from "./models/websocketServer.js";
import { testConnection } from './db.js';

// 初始化数据库连接
testConnection();

const httpServer = createServer(app.callback());
const wss = new WebSocketServerClass(httpServer);

const PORT = 3000;
httpServer.listen(PORT, () => {
  console.log(`Server is running at http://localhost:${PORT}`);
});
